<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
      <!-- <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">添加规则</a> -->
   	<!-- <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a> -->
	<a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="back()">返回</a>
	<div>
		<a class="easyui-linkbutton color1 l-btn l-btn-small" href="javascript:void(0)" onclick="javascript:save();" style="width: 220px;">
			 <span class="l-btn-center" style="margin-top: 0px;"><span class="l-btn-text">确定</span></span> 
		</a>
		<input type="hidden" value="${shop.id!''}" id="id"></input>
		<input type="hidden" value="${shop.searchNumber!''}" id="searchNumber"></input>
		<input type="hidden" value="${shop.balance!''}" id="balance"></input>
		<input type="hidden" value="${shop.name!''}" id="name"></input>
		<input type="hidden" value="${shop.remarks!''}" id="shopSet_id">
	</div>
</div>
	
<script type="text/javascript">
var shopId=$("#id").val();
var searchNumber=$("#searchNumber").val();
var balance=$("#balance").val();
var name=$("#name").val();

function save() {
	var rowsSel = datagrid.datagrid("getSelections");
	var dataarr= new Array();
	var ruleCode= new Array();
	var type= new Array();
	var description= new Array();
	var section= new Array();
	var ruleStore= new Array();
	for(var i=0;i<rowsSel.length;i++){
		dataarr[i] = rowsSel[i].id;
		ruleCode[i] = rowsSel[i].ruleCode;
		type[i] = rowsSel[i].type;
		description[i] = rowsSel[i].description;
		section[i] = rowsSel[i].section;
		ruleStore[i] = rowsSel[i].store;
	}
	 if(rowsSel.length <= 0) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	location.replace('datasave?dataarr='+dataarr.toString()+'&shopId='+shopId+'&ruleCode='+ruleCode.toString()+'&type='+type.toString()+'&description='+description.toString()+'&section='+section.toString()+'&ruleStore='+ruleStore.toString()+"&setId="+$("#shopSet_id").val()+"&name="+name+"&balance="+balance+"&searchNumber="+searchNumber); 
}

var datagrid = $("#dg");

var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'detailDataList?shopId='+shopId,
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:false,
        columns: [[
					{field:'ruleCode', title: '规则编号', width:100}
		           ,{field:'type',title: '规则类型', width:80}
				   ,{field:'description',title: '规则描述', width:280}
				   ,{field:'section', title: '规则区间', width:100}
				   ,{field:'store',title: '分值', width:80}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});
		
function back() {
	location.replace("search?id="+shopId+"&name="+name+"&balance="+balance+"&searchNumber="+searchNumber+"&setId="+$("#shopSet_id").val());
}

function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var name = rowsSel[0].name;
	confirmMsg("确认删除吗？", function() {
/* 		var bb="";
		for (var i = 0; i < rowsSel.length; i++) {
			var aa = rowsSel[i].positionid;
			bb = aa + "|" +bb;
		} */
		var name = rowsSel[0].name;
		$.post("delete", {name: name}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}

</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>